#ifndef PD_LOG_H_
#define PD_LOG_H_

#include <sys/time.h>
#include <stdio.h>
#include <stdint.h>
#include "pd_define.h"

#define FATAL
#define WARN
#define INFO
#define TRACE
#define DEBUG

#define PD_FATAL    "FATAL"
#define PD_WARN     "WARN"
#define PD_INFO     "INFO"
#define PD_TRACE    "TRACE"
#define PD_DEBUG    "DEBUG"

#define PD_LOG(_loglevel_, _fmt_, args...) \
    do \
    { \
        struct timeval log_tm;\
        gettimeofday(&log_tm, NULL);\
        fprintf(stderr, \
                "[%s] [%s][%s][%ld] %lu [%s][%d][%s] " _fmt_ "\n", \
                PD_##_loglevel_, \
                __DATE__, __TIME__, log_tm.tv_usec, \
                GETTID(), __FILE__, __LINE__, __FUNCTION__, \
                ##args); \
    } while (0) \

#endif
